#coding:utf-8
from telnetlib import EC
from selenium import webdriver
from bs4 import BeautifulSoup
from time import sleep

from webCrawler import WebCrawler

# from selenium.webdriver.common.by import By
# from selenium.webdriver.support.wait import WebDriverWait #等待页面加载某些元素
# from selenium import webdriver
# from selenium.webdriver import ChromeOptions
# import datetime
#
# option = ChromeOptions()
#         # option.add_argument("--headless")
#         # option.add_argument("--disable-gpu")
# option.add_experimental_option('excludeSwitches', ['enable-automation'])
# option.add_experimental_option('useAutomationExtension', False)
# wd = webdriver.Chrome(options=option, executable_path=r'd:\chromedriver.exe')
# wd.execute_cdp_cmd('Page.addScriptToEvaluateOnNewDocument', {
#     'source': 'Object.defineProperty(navigator, "webdriver", {get: () => undefined})'
# })
# wd.implicitly_wait(10)

#wd=webdriver.Chrome()
# wd=webdriver.Chrome(r'd:\chromedriver.exe')
#wd=webdriver.Firefox()
#wd.get('https://vacations.ctrip.com/list/grouptravel/sc.html?sv=%E4%B8%89%E4%BA%9A&startcity=2')


wd.get('https://www.ctrip.com/')
wd.implicitly_wait(3)
h1 = wd.current_window_handle
wd.find_element_by_id('nav_vac').click()
wd.find_element_by_class_name('start_city_station').click()
wd.find_element_by_link_text('上海').click()
wd.implicitly_wait(2)
wd.find_element_by_xpath("//*[@class='destination_col']//p//a").click()
hanales=wd.window_handles
wd.switch_to.window(hanales.pop())
print(wd.current_url)
data=wd.find_elements_by_class_name('list_product_right')
#记录当前网址

print(data)


